﻿using System;
using System.Collections.Generic;
using System.Text;
using SIOsystem.Model.OperatorDataSetTableAdapters;

namespace SIOsystem.Control
{
    class OperatorClass
    {
        static public bool addOperator(string opName,string opPasswd,long RID)
        {
            try
            {
                using (OperatorTableAdapter db = new OperatorTableAdapter())
                {
                    if (opName != "" && opPasswd != "" && db.InsertOperator(opName, opPasswd, RID) > 0)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("增加操作员出错", ex);
            }
        }

        static public bool modPassword(string passwaord, long OID)
        {
            try
            {
                using (OperatorTableAdapter db = new OperatorTableAdapter())
                {
                    if (db.UpdatePassword(passwaord, OID) > 0)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("修改操作员出错", ex);
            }
        }
        static public bool modRole(long RID, long OID)
        {
            try
            {
                using (OperatorTableAdapter db = new OperatorTableAdapter())
                {
                    if (db.UpdateRole(RID, OID) > 0)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("修改操作员角色出错", ex);
            }
        }
    }
}
